<?php

namespace app\uniapp\service\traits;


use app\model\site\Site;
use app\model\site\User;
use app\uniapp\service\UniAuthService;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

trait BaseTrait
{

    protected Site $site;
    protected int $siteId;
    protected User|null $user;
    protected int $userId;

    /**
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws DataNotFoundException
     */
    public function __construct()
    {
        $site = UniAuthService::instance()->getCurrentSite();
        $this->site = $site;
        $this->siteId = $site->id;
        $this->user = UniAuthService::instance()->getLoginInfo();
        $this->userId = UniAuthService::instance()->getLoginId();
    }
}
